<template>
  <div class="consultations">
    <div class="container">
      <h1>美容咨询中心</h1>
      <p class="subtitle">专业美容建议和护肤知识，为您解答美丽疑惑</p>
      
      <!-- Consultation Form -->
      <div class="consultation-form">
        <h2>在线咨询</h2>
        <form @submit.prevent="submitConsultation">
          <div class="form-group">
            <label for="name">姓名</label>
            <input 
              type="text" 
              id="name" 
              v-model="formData.name" 
              placeholder="请输入您的姓名"
              required
            >
          </div>
          <div class="form-group">
            <label for="phone">电话</label>
            <input 
              type="tel" 
              id="phone" 
              v-model="formData.phone" 
              placeholder="请输入您的联系电话"
              required
            >
          </div>
          <div class="form-group">
            <label for="question">咨询问题</label>
            <textarea 
              id="question" 
              v-model="formData.question" 
              placeholder="请描述您的皮肤问题或美容需求"
              rows="4"
              required
            ></textarea>
          </div>
          <button type="submit" class="submit-btn">提交咨询</button>
        </form>
      </div>
      
      <!-- FAQ Section -->
      <div class="faq-section">
        <h2>常见问题</h2>
        <div class="faq-list">
          <div 
            class="faq-item" 
            v-for="(faq, index) in faqs" 
            :key="index"
            @click="toggleFaq(index)"
          >
            <div class="faq-question">
              <h3>{{ faq.question }}</h3>
              <span class="faq-icon">{{ faq.open ? '−' : '+' }}</span>
            </div>
            <div class="faq-answer" v-if="faq.open">
              <p>{{ faq.answer }}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Consultations',
  data() {
    return {
      formData: {
        name: '',
        phone: '',
        question: ''
      },
      knowledgeArticles: [
        {
          id: 1,
          title: '如何正确选择适合自己肤质的护肤品',
          category: '护肤知识',
          excerpt: '了解不同肤质的特点和护理要点，选择最适合的护肤品...',
          date: '2024-01-15',
          image: 'https://images.unsplash.com/photo-1556228720-d195d15d2b0a?w=400&h=250&fit=crop'
        },
        {
          id: 2,
          title: '冬季皮肤保养的五大要点',
          category: '季节护理',
          excerpt: '冬季干燥寒冷，皮肤容易出现问题，这些保养技巧帮你度过寒冬...',
          date: '2024-01-10',
          image: 'https://images.unsplash.com/photo-1570194065657-4e29a14b328d?w=400&h=250&fit=crop'
        },
        {
          id: 3,
          title: '抗衰老的正确方法和误区',
          category: '抗衰老',
          excerpt: '科学抗衰老，避免常见误区，让肌肤保持年轻状态...',
          date: '2024-01-08',
          image: 'https://images.unsplash.com/photo-1599351431202-1e0f0137899a?w=400&h=250&fit=crop'
        }
      ],
      faqs: [
        {
          question: '如何判断自己的肤质类型？',
          answer: '可以通过观察皮肤出油情况、毛孔大小、皮肤纹理等来判断。油性皮肤通常T区出油明显，干性皮肤容易起皮，混合性皮肤T区油两颊干，中性皮肤状态均衡。',
          open: false
        },
        {
          question: '护肤品需要经常更换吗？',
          answer: '不建议频繁更换护肤品。皮肤需要时间适应产品，一般建议使用一个产品至少28天（一个皮肤代谢周期）后再评估效果。如果产品适合，可以长期使用。',
          open: false
        },
        {
          question: '美容护理的频率应该是多少？',
          answer: '基础护理建议每周1-2次，专业护理如深层清洁、抗衰老护理等建议每2-4周一次。具体频率应根据个人肤质和需求调整。',
          open: false
        },
        {
          question: '敏感肌肤应该如何护理？',
          answer: '敏感肌肤应选择温和无刺激的产品，避免使用含酒精、香精等刺激性成分。护理时要轻柔，避免过度清洁和去角质。建议先进行皮肤测试。',
          open: false
        }
      ]
    }
  },
  methods: {
    submitConsultation() {
      alert(`感谢您的咨询！\n姓名: ${this.formData.name}\n电话: ${this.formData.phone}\n我们将尽快联系您解答问题。`);
      this.formData = { name: '', phone: '', question: '' };
    },
    readArticle(article) {
      alert(`阅读文章: ${article.title}\n\n${article.excerpt}\n\n更多详细内容请关注我们的更新。`);
    },
    toggleFaq(index) {
      this.faqs = this.faqs.map((faq, i) => ({
        ...faq,
        open: i === index ? !faq.open : false
      }));
    }
  }
}
</script>

<style scoped>
.consultations {
  padding: 4rem 0;
  background: #f8f9fa;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

h1 {
  text-align: center;
  font-size: 2.5rem;
  color: #333;
  margin-bottom: 1rem;
}

.subtitle {
  text-align: center;
  font-size: 1.2rem;
  color: #666;
  margin-bottom: 3rem;
}

.consultation-form {
  background: white;
  padding: 2rem;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  margin-bottom: 3rem;
}

.consultation-form h2 {
  color: #333;
  margin-bottom: 2rem;
  text-align: center;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: #333;
  font-weight: 600;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 1rem;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #667eea;
}

.submit-btn {
  width: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 1rem;
  border: none;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.submit-btn:hover {
  transform: translateY(-2px);
}

.knowledge-section,
.faq-section {
  margin-bottom: 3rem;
}

.knowledge-section h2,
.faq-section h2 {
  color: #333;
  margin-bottom: 2rem;
  text-align: center;
}

.knowledge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 2rem;
}

.knowledge-card {
  background: white;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  transition: transform 0.3s ease;
}

.knowledge-card:hover {
  transform: translateY(-5px);
}

.knowledge-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.knowledge-content {
  padding: 1.5rem;
}

.knowledge-content h3 {
  color: #333;
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.excerpt {
  color: #666;
  line-height: 1.6;
  margin-bottom: 1rem;
}

.article-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.category {
  background: #e3f2fd;
  color: #1976d2;
  padding: 0.3rem 0.8rem;
  border-radius: 15px;
  font-size: 0.8rem;
  font-weight: 500;
}

.date {
  color: #666;
  font-size: 0.9rem;
}

.read-more {
  width: 100%;
  background: #667eea;
  color: white;
  padding: 0.8rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.3s ease;
}

.read-more:hover {
  background: #5a6fd8;
}

.faq-list {
  background: white;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.faq-item {
  border-bottom: 1px solid #e9ecef;
  cursor: pointer;
  transition: background 0.3s ease;
}

.faq-item:last-child {
  border-bottom: none;
}

.faq-item:hover {
  background: #f8f9fa;
}

.faq-question {
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-question h3 {
  color: #333;
  font-size: 1.1rem;
  margin: 0;
}

.faq-icon {
  font-size: 1.5rem;
  font-weight: bold;
  color: #667eea;
}

.faq-answer {
  padding: 0 1.5rem 1.5rem;
}

.faq-answer p {
  color: #666;
  line-height: 1.6;
  margin: 0;
}

@media (max-width: 768px) {
  .knowledge-grid {
    grid-template-columns: 1fr;
  }
  
  .consultation-form {
    padding: 1.5rem;
  }
  
  .faq-question {
    padding: 1rem;
  }
  
  .faq-question h3 {
    font-size: 1rem;
  }
  
  h1 {
    font-size: 2rem;
  }
}
</style>